package com.sunlands.zlcx.usercenter.vo.share;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.sunlands.zlcx.usercenter.domain.share.UserShareCardDO;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class UserShareCardVO implements Serializable {

    private static final long serialVersionUID = -8448205584465806848L;
    private Long id;
    @ApiModelProperty(value = "分享id")
    private Long shareId;
    @ApiModelProperty(value = "学习id")
    private Long learnId;
    @ApiModelProperty(value = "打卡用户id")
    private Long cardUserId;
    @ApiModelProperty(value = "打卡用户名称")
    private String cardUserName;
    @ApiModelProperty(value = "打卡用户头像")
    private String cardUserAvatar;
    @ApiModelProperty(value = "打卡内容")
    private String cardContent;
    @ApiModelProperty(value = "分享用户id")
    private Long shareUserId;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @ApiModelProperty(value = "打卡时间")
    private Date createTime;

    public static UserShareCardVO from(UserShareCardDO userShareCardDO) {
        return Objects.isNull(userShareCardDO) ? null : UserShareCardVO.builder()
                .id(userShareCardDO.getId())
                .cardContent(userShareCardDO.getCardContent())
                .cardUserId(userShareCardDO.getCardUserId())
                .createTime(userShareCardDO.getCreateTime())
                .learnId(userShareCardDO.getLearnId())
                .shareId(userShareCardDO.getShareId())
                .shareUserId(userShareCardDO.getShareUserId())
                .build();
    }

}
